package jnpf.service.impl;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.databind.ObjectMapper;
import jnpf.base.UserInfo;
import jnpf.base.entity.VisualdevEntity;
import jnpf.base.service.VisualdevService;
import jnpf.base.util.VisualUtils;
import jnpf.config.PermissionsConfig;
import jnpf.engine.entity.FlowTaskEntity;
import jnpf.engine.service.FlowTaskService;
import jnpf.entity.*;
import jnpf.exception.WorkFlowException;
import jnpf.mapper.ZXGL_XMCFZGBMJSMapper;
import jnpf.model.common.ZXGL_XzbmLeaders;
import jnpf.model.zxgl_xiangmuzhipaixiebanrenzhubiao.ZXGL_XiangMuZhiPaiXieBanRenMingXiBiaoModel;
import jnpf.model.zxgl_xiangmuzhipaixiebanrenzhubiao.ZXGL_XiangMuZhiPaiXieBanRenZhuBiaoCrForm;
import jnpf.model.zxgl_xmcfzgbmjs.ZXGL_XMCFZGBMJSPagination;
import jnpf.permission.entity.OrganizeEntity;
import jnpf.permission.entity.UserEntity;
import jnpf.permission.service.AuthorizeService;
import jnpf.permission.service.OrganizeService;
import jnpf.permission.service.UserService;
import jnpf.service.*;
import jnpf.util.JsonUtil;
import jnpf.util.RandomUtil;
import jnpf.util.StringUtil;
import jnpf.util.UserProvider;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.lang.reflect.Field;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * ZXGL_XMCFZGBMJS
 * 版本： V2.0
 * 版权： 河北交投智能交通技术有限责任公司
 * 作者： 数字交投项目组
 * 日期： 2025-03-19
 */
@Service
public class ZXGL_XMCFZGBMJSServiceImpl extends ServiceImpl<ZXGL_XMCFZGBMJSMapper, ZXGL_XMCFZGBMJSEntity> implements ZXGL_XMCFZGBMJSService {
    private static final Logger logger = LoggerFactory.getLogger(ZXGL_XMCFZGBMJSService.class);

    @Autowired
    private UserProvider userProvider;

    @Autowired
    private ZXGL_XMCFZGBMJS_MingXiService zXGL_XMCFZGBMJS_MingXiService;

    @Autowired
    private ZXGL_LiXiangGuanLiService zxglLiXiangGuanLiService;

    @Autowired
    private ZXGL_XiangMuLiXiang_MingXiService zxglXiangMuLiXiangMingXiService;

    @Autowired
    private ObjectMapper objectMapper;

    @Autowired
    private AuthorizeService authorizeService;

    @Resource
    PermissionsConfig permissionsConfig;

    @Autowired
    private ZXGL_OrganizeService zxglOrganizeService;

    @Autowired
    private ZXGL_XiangMuZhiPaiXieBanRenZhuBiaoService zxglXiangMuZhiPaiXieBanRenZhuBiaoService;

    @Autowired
    private ZXGL_XiangMuZhiPaiXieBanRenMingXiBiaoService zxglXiangMuZhiPaiXieBanRenMingXiBiaoService;

    @Autowired
    private VisualdevService visualdevService;

    @Autowired
    private FlowTaskService flowTaskService;

    @Autowired
    private UserService userService;

    @Autowired
    private OrganizeService organizeService;

    @Override
    public List<ZXGL_XMCFZGBMJSEntity> getList(ZXGL_XMCFZGBMJSPagination zXGL_XMCFZGBMJSPagination) {
        List<String> AllIdList = new ArrayList();
        int total = 0;
        QueryWrapper<ZXGL_XMCFZGBMJSEntity> zXGL_XMCFZGBMJSQueryWrapper = new QueryWrapper<>();
        QueryWrapper<ZXGL_XMCFZGBMJS_MingXiEntity> zXGL_XMCFZGBMJS_MingXiQueryWrapper = new QueryWrapper<>();
        //TODO 增加权限逻辑
        UserInfo userInfo = userProvider.get();
        if (!userInfo.getIsAdministrator()) {
            String alldataRoleId = permissionsConfig.getAlldataRoleid();
            List<String> roleIds = userInfo.getRoleIds();
            if (roleIds == null || (StringUtils.isNotBlank(alldataRoleId) && !roleIds.contains(alldataRoleId))) {
                //部门确认：创建人看本人数据；主责部门负责人看本部门数据；主责部门主管领导看所管理部门数据；指派人员查看本人数据；
                String userId = userInfo.getUserId();
                zXGL_XMCFZGBMJSQueryWrapper.lambda().and(wrapper -> wrapper
                        .eq(ZXGL_XMCFZGBMJSEntity::getDepartmentManagerZzbm, userId)//部门负责人
                        .or()
                        .eq(ZXGL_XMCFZGBMJSEntity::getDepartmentHeadleaderZzbm, userId) //部门主管领导
                        .or()
                        .eq(ZXGL_XMCFZGBMJSEntity::getZpry, userId)//指派人员
                        .or()
                        .eq(ZXGL_XMCFZGBMJSEntity::getCreatorUserId, userId)//创建人
                );
            }
        }
        int zXGL_XMCFZGBMJSNum = 0;
        if (StringUtil.isNotEmpty(zXGL_XMCFZGBMJSPagination.getDepartmentName())) {
            zXGL_XMCFZGBMJSNum++;
            zXGL_XMCFZGBMJSQueryWrapper.lambda().like(ZXGL_XMCFZGBMJSEntity::getDepartmentName, zXGL_XMCFZGBMJSPagination.getDepartmentName());
        }

        if (AllIdList.size() > 0) {
            zXGL_XMCFZGBMJSQueryWrapper.lambda().in(ZXGL_XMCFZGBMJSEntity::getId, AllIdList);
        }
/**
 * 数据权限 此处手动写入菜单id
 */
//        String moduleId = "671631335806236293";
//        if (!userProvider.get().getIsAdministrator()) {
//            Object conditionObj = authorizeService.getCondition(zXGL_XMCFZGBMJSQueryWrapper, userProvider.get(), moduleId);
//            if (ObjectUtil.isEmpty(conditionObj)) {
//                return new ArrayList<>();
//            }
//            zXGL_XMCFZGBMJSQueryWrapper = (QueryWrapper<ZXGL_XMCFZGBMJSEntity>) authorizeService.getCondition(zXGL_XMCFZGBMJSQueryWrapper, userProvider.get(), moduleId);
//        }
        //排序
//        if (StringUtil.isEmpty(zXGL_XMCFZGBMJSPagination.getSidx())) {
//            zXGL_XMCFZGBMJSQueryWrapper.lambda().orderByDesc(ZXGL_XMCFZGBMJSEntity::getId);
//        } else {
//            try {
//                String sidx = zXGL_XMCFZGBMJSPagination.getSidx();
//                ZXGL_XMCFZGBMJSEntity zXGL_XMCFZGBMJSEntity = new ZXGL_XMCFZGBMJSEntity();
//                Field declaredField = zXGL_XMCFZGBMJSEntity.getClass().getDeclaredField(sidx);
//                declaredField.setAccessible(true);
//                String value = declaredField.getAnnotation(TableField.class).value();
//                zXGL_XMCFZGBMJSQueryWrapper = "asc".equals(zXGL_XMCFZGBMJSPagination.getSort().toLowerCase()) ? zXGL_XMCFZGBMJSQueryWrapper.orderByAsc(value) : zXGL_XMCFZGBMJSQueryWrapper.orderByDesc(value);
//            } catch (NoSuchFieldException e) {
//                e.printStackTrace();
//            }
//        }
        zXGL_XMCFZGBMJSQueryWrapper.lambda().orderByDesc(ZXGL_XMCFZGBMJSEntity::getCreatorTime);
        if ((total > 0 && AllIdList.size() > 0) || total == 0) {
            Page<ZXGL_XMCFZGBMJSEntity> page = new Page<>(zXGL_XMCFZGBMJSPagination.getCurrentPage(), zXGL_XMCFZGBMJSPagination.getPageSize());
            IPage<ZXGL_XMCFZGBMJSEntity> userIPage = this.page(page, zXGL_XMCFZGBMJSQueryWrapper);
            return zXGL_XMCFZGBMJSPagination.setData(userIPage.getRecords(), userIPage.getTotal());
        } else {
            List<ZXGL_XMCFZGBMJSEntity> list = new ArrayList();
            return zXGL_XMCFZGBMJSPagination.setData(list, list.size());
        }
    }

    @Override
    public List<ZXGL_XMCFZGBMJSEntity> getTypeList(ZXGL_XMCFZGBMJSPagination zXGL_XMCFZGBMJSPagination, String dataType) {
        String userId = userProvider.get().getUserId();
        List<String> AllIdList = new ArrayList();
        int total = 0;
        QueryWrapper<ZXGL_XMCFZGBMJSEntity> zXGL_XMCFZGBMJSQueryWrapper = new QueryWrapper<>();
        QueryWrapper<ZXGL_XMCFZGBMJS_MingXiEntity> zXGL_XMCFZGBMJS_MingXiQueryWrapper = new QueryWrapper<>();
        int zXGL_XMCFZGBMJSNum = 0;
        if (StringUtil.isNotEmpty(zXGL_XMCFZGBMJSPagination.getDepartmentName())) {
            zXGL_XMCFZGBMJSNum++;
            zXGL_XMCFZGBMJSQueryWrapper.lambda().eq(ZXGL_XMCFZGBMJSEntity::getDepartmentName, zXGL_XMCFZGBMJSPagination.getDepartmentName());
        }

        if (AllIdList.size() > 0) {
            zXGL_XMCFZGBMJSQueryWrapper.lambda().in(ZXGL_XMCFZGBMJSEntity::getId, AllIdList);
        }
        //排序
        if (StringUtil.isEmpty(zXGL_XMCFZGBMJSPagination.getSidx())) {
            zXGL_XMCFZGBMJSQueryWrapper.lambda().orderByDesc(ZXGL_XMCFZGBMJSEntity::getId);
        } else {
            try {
                String sidx = zXGL_XMCFZGBMJSPagination.getSidx();
                ZXGL_XMCFZGBMJSEntity zXGL_XMCFZGBMJSEntity = new ZXGL_XMCFZGBMJSEntity();
                Field declaredField = zXGL_XMCFZGBMJSEntity.getClass().getDeclaredField(sidx);
                declaredField.setAccessible(true);
                String value = declaredField.getAnnotation(TableField.class).value();
                zXGL_XMCFZGBMJSQueryWrapper = "asc".equals(zXGL_XMCFZGBMJSPagination.getSort().toLowerCase()) ? zXGL_XMCFZGBMJSQueryWrapper.orderByAsc(value) : zXGL_XMCFZGBMJSQueryWrapper.orderByDesc(value);
            } catch (NoSuchFieldException e) {
                e.printStackTrace();
            }
        }
        if ("0".equals(dataType)) {
            if ((total > 0 && AllIdList.size() > 0) || total == 0) {
                Page<ZXGL_XMCFZGBMJSEntity> page = new Page<>(zXGL_XMCFZGBMJSPagination.getCurrentPage(), zXGL_XMCFZGBMJSPagination.getPageSize());
                IPage<ZXGL_XMCFZGBMJSEntity> userIPage = this.page(page, zXGL_XMCFZGBMJSQueryWrapper);
                return zXGL_XMCFZGBMJSPagination.setData(userIPage.getRecords(), userIPage.getTotal());
            } else {
                List<ZXGL_XMCFZGBMJSEntity> list = new ArrayList();
                return zXGL_XMCFZGBMJSPagination.setData(list, list.size());
            }
        } else {
            return this.list(zXGL_XMCFZGBMJSQueryWrapper);
        }
    }

    @Override
    public ZXGL_XMCFZGBMJSEntity getInfo(String id) {
        QueryWrapper<ZXGL_XMCFZGBMJSEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(ZXGL_XMCFZGBMJSEntity::getId, id);
        return this.getOne(queryWrapper);
    }

    @Override
    public void create(ZXGL_XMCFZGBMJSEntity entity) {
        this.save(entity);
    }

    @Override
    public boolean update(String id, ZXGL_XMCFZGBMJSEntity entity) {
        entity.setId(id);
        return this.updateById(entity);
    }

    @Override
    public void delete(ZXGL_XMCFZGBMJSEntity entity) {
        if (entity != null) {
            this.removeById(entity.getId());
        }
    }

    @Override
    public ZXGL_XMCFZGBMJSEntity getInfoByXmixdID(String id) {
        QueryWrapper<ZXGL_XMCFZGBMJSEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(ZXGL_XMCFZGBMJSEntity::getXmlxdid, id);
        return this.getOne(queryWrapper);
    }

    @Override
    public boolean deleteByXmlxdid(String xmlxdid) {
        QueryWrapper<ZXGL_XMCFZGBMJSEntity> deleteWrapper = new QueryWrapper<>();
        deleteWrapper.lambda().eq(ZXGL_XMCFZGBMJSEntity::getXmlxdid, xmlxdid);
        return this.remove(deleteWrapper);
    }


    //子表方法
    @Override
    public List<ZXGL_XMCFZGBMJS_MingXiEntity> GetZXGL_XMCFZGBMJS_MingXiList(String id) {
        QueryWrapper<ZXGL_XMCFZGBMJS_MingXiEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(ZXGL_XMCFZGBMJS_MingXiEntity::getMainid, id);
        return zXGL_XMCFZGBMJS_MingXiService.list(queryWrapper);
    }

    /**
     * 生成项目编号并更新部门确认明细表
     *
     * @param id
     */
    private void generateXmbh(String id) {
        String prefix = "ZXGL-" + DateUtil.format(LocalDateTime.now(), "yyyyMMdd"); // ZXGL-202504020001
        logger.info(prefix);
        String strNum = zXGL_XMCFZGBMJS_MingXiService.findMaxSequence(prefix);

        Long num;
        if (StringUtil.isEmpty(strNum)) {
            num = 0l;
        } else {
            num = Long.parseLong(strNum);
        }
        num++;
        List<ZXGL_XMCFZGBMJS_MingXiEntity> updateList = new ArrayList<>();
        List<ZXGL_XMCFZGBMJS_MingXiEntity> list = GetZXGL_XMCFZGBMJS_MingXiList(id);
        for (ZXGL_XMCFZGBMJS_MingXiEntity entity : list) {
            if (entity.getJszt().equals("669883054189213317")) {
                String sequence = prefix + String.format("%04d", num);
                entity.setXmbh(sequence);
                updateList.add(entity);
                num++;
            }
        }
        boolean update = true;
        if (updateList.size() > 0) {
            zXGL_XMCFZGBMJS_MingXiService.updateBatchById(updateList);
        }
    }

    /**
     * 根据部门确认明细信息更新立项管理明细表项目接收状态等数据
     * 根据立项管理项目总数和接收数量是否一致确定是否针对当前立项管理所有明细项目发起指派协办人流程
     *
     * @param id
     */
    private void updateLiXiangInfo(String id) {
        // 查询项目立项分解到部门主表
        ZXGL_XMCFZGBMJSEntity zxglXmcfzgbmjsEntity = getInfo(id);
        // 查询项目立项分解到部门明细表
        List<ZXGL_XMCFZGBMJS_MingXiEntity> zxglXmcfzgbmjsMingXiEntities = GetZXGL_XMCFZGBMJS_MingXiList(id);
        // 项目立项表信息
        ZXGL_LiXiangGuanLiEntity zxglLiXiangGuanLiEntity = zxglLiXiangGuanLiService.getInfo(zxglXmcfzgbmjsEntity.getXmlxdid());
        // 读取项目明细表
        List<ZXGL_XiangMuLiXiang_MingXiEntity> list = zxglLiXiangGuanLiService.GetZXGL_XiangMuLiXiang_MingXiList(zxglLiXiangGuanLiEntity.getId());

        List<ZXGL_XiangMuLiXiang_MingXiEntity> updateList = new ArrayList<>();
        for (ZXGL_XMCFZGBMJS_MingXiEntity entity : zxglXmcfzgbmjsMingXiEntities) {
            ZXGL_XiangMuLiXiang_MingXiEntity model = list.stream().filter(o -> o.getId().equals(entity.getXmid())).findFirst().orElse(null);

            logger.info("model=================================>" + model);

            if (model != null) {
                // 接收状态
                model.setJszt(entity.getJszt());
                // 项目编号
                model.setXmbh(entity.getXmbh());
                // 项目类型
                model.setXmlx(entity.getXmlx());
                // 目标值
                model.setMbz(entity.getMbz());
                // 责任人
                model.setZzr(entity.getZrr());
                // 协作人
                model.setXzr(entity.getXzr());
                updateList.add(model);
            }
        }


        if (updateList.size() > 0) {

            boolean update = zxglXiangMuLiXiangMingXiService.updateBatchById(updateList);

            if (update) {
                // 根据主表中的立项表单id更新项目立项主表中的待接收、接收、拒接字段中的数值：待接收数=待接收数-本次接收-本次拒接；接收数=接收数+本次接收数；拒接数=拒接数+本次拒接数；
                // List<ZXGL_XiangMuLiXiang_MingXiEntity> list = zxglLiXiangGuanLiService.GetZXGL_XiangMuLiXiang_MingXiList(zxglLiXiangGuanLiEntity.getId());
                Long jsNum = list.stream().filter(o -> "669883054189213317".equals(o.getJszt())).count();
                Long jjNum = list.stream().filter(o -> "669883022308308613".equals(o.getJszt())).count();
                Long djsNum = list.stream().filter(o -> !"669883022308308613".equals(o.getJszt()) && !"669883054189213317".equals(o.getJszt())).count();

                zxglLiXiangGuanLiEntity.setJsxms(jsNum.intValue());
                zxglLiXiangGuanLiEntity.setJjxms(jjNum.intValue());
                zxglLiXiangGuanLiEntity.setDqrxms(djsNum.intValue());
                zxglLiXiangGuanLiService.updateById(zxglLiXiangGuanLiEntity);

                // 如果项目总数和接收项目数一致则生成指派协办人数据并发起指派协办人流程
                if (zxglLiXiangGuanLiEntity.getXmzs().equals(zxglLiXiangGuanLiEntity.getJsxms())) {
                    startZpxbrFlow(zxglLiXiangGuanLiEntity, list);
                }
            }
        }
    }

    /**
     * 发起指派协办人流程
     * @param entity
     * @param list
     */
    private void startZpxbrFlow(ZXGL_LiXiangGuanLiEntity entity, List<ZXGL_XiangMuLiXiang_MingXiEntity> list) {
        String strXzbmIds = list.stream().filter(o -> StrUtil.isNotEmpty(o.getXzbm())).map(ZXGL_XiangMuLiXiang_MingXiEntity::getXzbm).collect(Collectors.joining(","));
        List<String> xzbmIds = Arrays.asList(strXzbmIds.split(","));
        xzbmIds = xzbmIds.stream().filter(val -> StrUtil.isNotEmpty(val)).distinct().collect(Collectors.toList());
        for (String xzbmId : xzbmIds) {
            ZXGL_XiangMuZhiPaiXieBanRenZhuBiaoEntity model = new ZXGL_XiangMuZhiPaiXieBanRenZhuBiaoEntity();
            // region 主表
            model.setId(RandomUtil.uuId());
            model.setHyjy(entity.getScfj()); // 会议纪要
            model.setXmlxdid(entity.getId()); // 项目立项单ID
            model.setXzbm(xzbmId);  // 协作部门
            ZXGL_XzbmLeaders leaders = zxglOrganizeService.getXzbmLeaders(xzbmId);
            model.setDepartmentManagerXzbm(leaders.getDepartmentManagerXzbm());
            model.setDepartmentHeadleaderXzbm(leaders.getDepartmentHeadleaderXzbm());
            model.setCreatorUser(entity.getCreatorUser());
            model.setCreatorUserId(entity.getCreatorUserId());
            model.setCompanyId(entity.getCompanyId());
            model.setCompanyName(entity.getCompanyName());
            model.setOrganizeId(entity.getOrganizeId());
            model.setOrganizeName(entity.getOrganizeName());
            model.setDepartmentId(entity.getDepartmentId());
            model.setDepartmentName(entity.getDepartmentName());
            // endregion

            boolean save = zxglXiangMuZhiPaiXieBanRenZhuBiaoService.save(model);

            if (save) {
                List<ZXGL_XiangMuZhiPaiXieBanRenMingXiBiaoEntity> models = new ArrayList<>();
                list.stream().filter(o -> o.getXzbm().contains(xzbmId)).forEach(o -> {
                    // region 明细表
                    ZXGL_XiangMuZhiPaiXieBanRenMingXiBiaoEntity mingxiModel = new ZXGL_XiangMuZhiPaiXieBanRenMingXiBiaoEntity();
                    mingxiModel.setId(RandomUtil.uuId());
                    mingxiModel.setMainid(model.getId());
                    mingxiModel.setXmid(o.getId());
                    mingxiModel.setXmmc(o.getXmmc());
                    mingxiModel.setXmlx(o.getXmlx());
                    mingxiModel.setJhkssj(o.getJhkssj());
                    mingxiModel.setJhjssj(o.getJhjssj());
                    mingxiModel.setFkzq(o.getFkzq());
                    mingxiModel.setXmly(o.getXmly());
                    // mingxiModel.setXzr(o.getXzr());
                    // mingxiModel.setXzbm(o.getXzbm());
                    mingxiModel.setMbz(o.getMbz());
                    mingxiModel.setMblx(o.getMblx());
                    mingxiModel.setMbdw(o.getMbzdw());
                    mingxiModel.setXmmb(o.getGzmb());
                    mingxiModel.setXmlxdid(entity.getId());
                    mingxiModel.setXzbm(xzbmId);

                    mingxiModel.setCreatorUser(entity.getCreatorUser());
                    mingxiModel.setCreatorUserId(entity.getCreatorUserId());
                    mingxiModel.setCompanyId(entity.getCompanyId());
                    mingxiModel.setCompanyName(entity.getCompanyName());
                    mingxiModel.setOrganizeId(entity.getOrganizeId());
                    mingxiModel.setOrganizeName(entity.getOrganizeName());
                    mingxiModel.setDepartmentId(entity.getDepartmentId());
                    mingxiModel.setDepartmentName(entity.getDepartmentName());
                    // endregion
                    models.add(mingxiModel);
                });

                save = zxglXiangMuZhiPaiXieBanRenMingXiBiaoService.saveBatch(models);

                if (save) {
                    ZXGL_XiangMuZhiPaiXieBanRenZhuBiaoCrForm form = JsonUtil.getJsonToBean(model, ZXGL_XiangMuZhiPaiXieBanRenZhuBiaoCrForm.class);
                    List<ZXGL_XiangMuZhiPaiXieBanRenMingXiBiaoModel> zxgl_xiangmuzhipaixiebanrenmingxibiaoList = JsonUtil.getJsonToList(models, ZXGL_XiangMuZhiPaiXieBanRenMingXiBiaoModel.class);
                    form.setZxgl_xiangmuzhipaixiebanrenmingxibiaoList(zxgl_xiangmuzhipaixiebanrenmingxibiaoList);
                    try {
                        String visualId = "680057614092023749";
                        VisualdevEntity visualdevEntity = visualdevService.getInfo(visualId);
                        UserEntity userEntity = userService.getById(model.getCreatorUserId());
                        UserInfo userInfo = userService.copyFromEntity(userEntity);
                        OrganizeEntity organize = organizeService.getInfoById(model.getXzbm());
                        VisualUtils.submitFlowTask(visualdevEntity, model.getId(), form, userInfo, form.getCandidateList());
                        FlowTaskEntity flowTaskEntity = flowTaskService.getInfo(model.getId());
                        if (flowTaskEntity != null) {
                            flowTaskEntity.setTitle(entity.getBt() + "-指派协作人-" + organize.getFullName() + "-" + DateUtil.today());
                            flowTaskEntity.setDataTable("zxgl_xiangmuzhipaixiebanrenzhubiao");
                            flowTaskService.update(flowTaskEntity);
                        }
                    } catch (WorkFlowException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }

    @Override
    public void updateInfo(String id) {
        try {
            // 当前流程调用为审批最后一个节点调用，所以更改是否上传知识库状态为2，通过定时器上传附件到知识库
            ZXGL_XMCFZGBMJSEntity model = this.getInfo(id);
            if (model != null) {
                model.setSfsczsk(2);
                updateById(model);
            }

            // 生成项目编号
            generateXmbh(id);
            // 更新立项信息
            updateLiXiangInfo(id);

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }


}